package com.zhijian.medical.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author HCG
 * @version 1.0
 * @date 2022/1/16
 */
@AllArgsConstructor
@Getter
public enum QuestionTypeEnum {

    SINGLE_SELECTION(0, "单选题"),
    MULTIPLE_SELECTION(1, "多选题"),
    FILL_BLANKS(2, "填空题"),

    SHORT_ANSWER(3, "简答题"),;

    private Integer code;
    private String type;

    public static QuestionTypeEnum getByCode(Integer code) {
        QuestionTypeEnum[] questionTypeEnums = QuestionTypeEnum.values();
        for (QuestionTypeEnum questionTypeEnum : questionTypeEnums) {
            if (questionTypeEnum.getCode().equals(code)) {
                return questionTypeEnum;
            }
        }
        return null;
    }

    public static QuestionTypeEnum getByType(String type) {
        QuestionTypeEnum[] questionTypeEnums = QuestionTypeEnum.values();
        for (QuestionTypeEnum questionTypeEnum : questionTypeEnums) {
            if (questionTypeEnum.getType().equals(type)) {
                return questionTypeEnum;
            }
        }
        return null;
    }
}
